﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TreeTraversal
{
    public partial class BorderlessTextBox : UserControl
    {
        public BorderlessTextBox()
        {
            InitializeComponent();
            textBox1.GotFocus += textBox1_GotFocus;
            textBox1.LostFocus += textBox1_LostFocus;
        }

        void textBox1_LostFocus(object sender, EventArgs e)
        {
            this.OnLostFocus(e);
        }

        void textBox1_GotFocus(object sender, EventArgs e)
        {
            this.OnGotFocus(e);
        }

        private void textBox1_BackColorChanged(object sender, EventArgs e)
        {
            tableLayoutPanel1.BackColor = textBox1.BackColor;
        }

        public TextBox TextBox { get { return textBox1; } }

        private void BorderlessTextBox_Click(object sender, EventArgs e)
        {
            textBox1.Focus();
        }

        private void tableLayoutPanel1_Click(object sender, EventArgs e)
        {
            textBox1.Focus();
        }

        HashSet<object> m_MouseEnteredObject = new HashSet<object>();
        private void Generic_MouseEnter(object sender, EventArgs e)
        {
            if (m_MouseEnteredObject.Count == 0)
            {
                this.OnMouseEnter(e);
            }

            m_MouseEnteredObject.Add(sender);
        }

        private void Generic_MouseLeave(object sender, EventArgs e)
        {
            m_MouseEnteredObject.Remove(sender);

            if (m_MouseEnteredObject.Count == 0)
            {
                this.OnMouseLeave(e);
            }
        }


    }
}
